package com.momo.hr.service.system;

import com.momo.hr.bean.Position;
import com.momo.hr.mapper.PositionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PositionService {

    @Autowired
    PositionMapper positionMapper;

    public List<Position> getAllPosition(){
        return this.positionMapper.getAllPositions();
    }

    public int addPosition(Position position) {
        //设置两个默认值
        position.setCreateDate(new Date());
        position.setEnabled(true);
        return this.positionMapper.insertSelective(position);
    }

    public int updatePosition(Position position){
        return this.positionMapper.updateByPrimaryKeySelective(position);
    }

    public int deletePosition(Integer id) {
        return this.positionMapper.deleteByPrimaryKey(id);
    }

    public int deletePositionsInBatches(Integer[] ids) {
        return this.positionMapper.deletePositionsByIds(ids);
    }
}
